﻿using System;
using Pixysoft.Framework.XSchEmA.Entity;
using System.Data;
namespace Pixysoft.Framework.XSchEmA
{
    public interface IDbMetadata
    {
        void CreateDatabase(ISchemaCommand command, string databasename);

        void DropDatabase(ISchemaCommand command, string databasename);

        bool Clear(DatabaseInfo info, DatabaseSchema schema);

        bool Clear(ISchemaCommand command, DatabaseSchema schema);

        bool UpdateComment(DatabaseSchema updateFrom, DatabaseSchema updateTo);

        bool Update(ISchemaCommand command, DatabaseSchema updateFrom, DatabaseSchema updateTo);

        DataSet GetDataSet(DatabaseSchema schema);

        System.Collections.Generic.List<string> GetDataTypeList();

        DatabaseSchema GetSchema(DatabaseInfo info);

        DataSet GetStrongDataSet(DatabaseSchema schema);

        /// <summary>
        /// 根据表名取得表，如果不存在则报错
        /// </summary>
        /// <param name="schema"></param>
        /// <param name="tablename"></param>
        /// <returns></returns>
        DataTable GetStrongTable(DatabaseSchema schema, string tablename);

        /// <summary>
        /// 根据表名取得表，如果不存在则报错
        /// </summary>
        /// <param name="schema"></param>
        /// <param name="tablename"></param>
        /// <returns></returns>
        DataTable GetTable(DatabaseSchema schema, string tablename);

        /// <summary>
        /// 转换到特殊格式
        /// </summary>
        /// <param name="schema"></param>
        void TransformToSpecific(DatabaseSchema schema);

        /// <summary>
        /// 转换到DotNet数据格式 DataType = DotNetDataType 枚举
        /// </summary>
        /// <param name="schema"></param>
        void TransformToGeneral(DatabaseSchema schema);

        /// <summary>
        /// 插入表结构
        /// </summary>
        /// <param name="info"></param>
        /// <param name="schema"></param>
        /// <returns></returns>
        bool Commit(DatabaseInfo info, DatabaseSchema schema);

        /// <summary>
        /// 插入表结构 适合远程操作
        /// </summary>
        /// <param name="command"></param>
        /// <param name="schema"></param>
        /// <returns></returns>
        bool Commit(ISchemaCommand command, DatabaseSchema schema);

        /// <summary>
        /// 创建自增字段
        /// </summary>
        /// <param name="info"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        bool CreateAutoIncrement(DatabaseInfo info, ColumnSchema column);
    }
}
